/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 30318
 * Date: 2023-12-12
 * Time: 17:28
 */
abstract class Account {
    protected String name;
    protected String aid;
    protected double balance;

    public Account(String name, String aid) {
        this.name = name;
        this.aid = aid;
        this.balance = 0.0;
    }

    public abstract void deposit(double amount);
    public abstract boolean withdraw(double amount);
    public abstract double getBalance();
}

class CashAccount extends Account {
    private String cardType;

    public CashAccount(String name, String aid, String cardType) {
        super(name, aid);
        this.cardType = cardType;
    }

    public void changeCardType(String newCardType) {
        this.cardType = newCardType;
    }

    public void deposit(double amount) {
        this.balance += amount;
    }

    public boolean withdraw(double amount) {
        if (amount <= this.balance) {
            this.balance -= amount;
            return true;
        } else {
            return false;
        }
    }

    public double getBalance() {
        return this.balance;
    }
}

class CreditAccount extends Account {
    private char creditLevel;
    private double lineOfCredit;

    public CreditAccount(String name, String aid, char creditLevel) {
        super(name, aid);
        this.creditLevel = creditLevel;

        switch (creditLevel) {
            case 'A':
                this.lineOfCredit = 10000.0;
                break;
            case 'B':
                this.lineOfCredit = 5000.0;
                break;
            case 'C':
                this.lineOfCredit = 2000.0;
                break;
            case 'D':
                this.lineOfCredit = 1000.0;
                break;
        }
    }

    public double getLineOfCredit() {
        return this.lineOfCredit;
    }

    public void deposit(double amount) {
        this.balance += amount;
    }

    public boolean withdraw(double amount) {
        if (amount <= this.balance + this.lineOfCredit) {
            this.balance -= amount;
            return true;
        } else {
            return false;
        }
    }

    public double getBalance() {
        return this.balance;
    }

    public double findOverdraw() {
        return Math.max(0, -(this.balance));
    }
}

/*
public class Test {
    public static void main(String[] args) {
        Account credit = new CreditAccount("Mike", "01", 'A');
        Account debit = new CashAccount("Amy", "02", "Debit Card");

        credit.deposit(500);
        debit.deposit(500);

        debit.withdraw(200);
        credit.withdraw(200);

        debit.withdraw(400);
        credit.withdraw(400);

        System.out.println("Debit Account Balance: " + debit.getBalance());
        System.out.println("Credit Account Balance: " + credit.getBalance());

        CreditAccount creditAccount = (CreditAccount) credit;
        System.out.println("Credit Account Overdraw: " + creditAccount.findOverdraw());
    }
}
*/

/*
public class Test {
    public static void main(String[] args) {
        Deck d = new Deck();
        d.show();
        Card c = d.show(10);
        System.out.println(c.suit + c.rank);
    }
}
 */

public class Test {
    public static void main(String[] args) {
        Teacher teacher = new Teacher("T001", "张三", "教授");
        Course course = new Course("C001", "计算机科学基础", 48, 16, 4.0, teacher);
        System.out.println("课程名称：" + course.getName());
        System.out.println("任课教师：" + course.getTeacher().getName());
        System.out.println("任课教师职称：" + course.getTeacher().getTitle());
    }
}